<template>
  <div id="toast" v-if="isShow">
    <div>{{ text }}</div>
  </div>
</template>

<script>
export default {
  //   props: {
  //     text: String
  //   },
  data() {
    return {
      isShow: false,
      text: ''
    }
  },
  methods: {
    message(text, tiem = 2000) {
      this.isShow = true
      this.text = text

      setTimeout(() => {
        this.isShow = false
        this.text = ''
      }, tiem)
    }
  }
}
</script>

<style lang="less" scoped>
#toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  div {
    min-width: 100px;
    max-width: 200px;
    min-height: 30px;
    line-height: 30px;
    text-align: center;
    padding: 0 10px;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.8);
  }
}
</style>
